package com.symc.sims0213xfw.controller.college;

import com.symc.sims0213xfw.service.OperationStatusResult;
import com.symc.sims0213xfw.service.impl.CollegeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author: 凤文  沈阳医学院2019级医学信息工程 0213
 * @CreateTime: 2022/01/27 13:14
 * @Description:
 */
@WebServlet(name = "/updateCollegeServlet")
public class UpdateCollegeServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        String name = request.getParameter("name");
        PrintWriter out = response.getWriter();
        Long status = new CollegeServiceImpl().updateCollege(Integer.parseInt(id), name);
        if (status == OperationStatusResult.UNREASONABLE_DID) {

        } else if (status == OperationStatusResult.NAME_LENGTH_OUT_OF_BOUNDS) {

        } else if (status == OperationStatusResult.EXIST) {

        } else if (status == OperationStatusResult.SUCCESS) {

        } else if (status == OperationStatusResult.DEFEAT) {

        }
        out.write("<br>2秒后自动跳转到查看页面。。。");
        response.setHeader("refresh", "2;url=/SMIS0213xfw/listCollegeServlet");
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
